#include"QuickSort.h"

void QuickSort(int* arr, int left, int right)
{
	if (left >= right)
		return;
	int begin = left; int end = right;
	int pivot = begin; int key = arr[begin];
	while (begin < end)
	{
		while (arr[end]>key&&begin < end)
			end--;
		arr[pivot] = arr[end];
		pivot = end;
		while (arr[begin] < key&&begin < end)
			begin++;
		arr[pivot] = arr[begin];
		pivot = begin;
	}
	pivot = begin;
	arr[pivot] = key;
	QuickSort(arr, left, pivot - 1);
	QuickSort(arr, pivot + 1, right);
}
void Print(int* arr, int len)
{
	int i = 0;
	for (i = 0; i < len; i++)
		printf("%d ", arr[i]);
	printf("\n");
}